import com.troyworks.framework.logging.SOSLogger;
import com.troyworks.events.TDispatcher;
import com.troyworks.framework.logging.Logger;
import com.troyworks.events.TProxy;
/**
 * Demonstrates the multiple listeners to the object
 * @author Troy Gardner
 */
class com.troyworks.events.TestTDispatcher {
	public static var _libSOS:Function = SOSLogger;
	public var logger:Logger;
	//////////for the event dispatcher //////
	public var listenerExists:Function;
	public var addListener:Function;
	public var removeListener:Function;
	public var removeAllListeners:Function;
	public var notifyListeners:Function;
	/////////////////////////////////////////////
	public function TestTDispatcher() {
		logger = new SOSLogger("TestTDispatcher");
		TDispatcher.initialize(this);
		var o1:Object = new Object();
		o1.parent = this;
		o1.callback = function(){
			var res:Array = new Array();
			res.push("o1.callback\r\t"+ arguments.join("\r\t"));
			SOSLogger.getInstance().log( res.join(''));
			
		};
		//	logger.startSig( util.Trace.me(o1,"o1"));
		var o2:Object = new Object();
		o2.parent = this;
		o2.callback = function(){
			SOSLogger.getInstance().log("o2.callback\r\t"+ arguments.join("\r\t"));
		};
//		logger.endSig( util.Trace.me(o2,"o2"));
		
		logger.info("Adding Callbacks as Listeners");
		
		
		TProxy.currentUserName = "TestTDispatcher";
		trace("INFO  adding listeners");
		this.addListener(o1, o1.callback);
		this.addListener(o2, o2.callback, "o2UserArg1", "o2UserArg2");
		trace("INFO  notifying listeners");
		logger.info("NotifyingListeners");

		this.notifyListeners("RealA","RealB","RealC","RealD");

	}
	
	public static function main(container : MovieClip) : Void {
		trace("TestTProxy main");
		var t:TestTDispatcher = new TestTDispatcher();
	}
}